package com.xs.web.old;

import com.alibaba.fastjson.JSON;
import com.xs.pojo.Log;
import com.xs.service.LogSercice;
import com.xs.service.impl.LogSerciceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/selectServlet2")
public class SelectServlet2 extends HttpServlet {
    LogSercice logSercice=new LogSerciceImpl();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println(1);
        List<Log> logs = logSercice.SelectAll();

        //转换数据
        String s = JSON.toJSONString(logs);

        response.setContentType("text/json;charset=utf-8");
        response.getWriter().write(s);

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
